if(BUILD_RABBITMQ)
  if(RABBITMQ_FOUND)
    include_directories(${RABBITMQ_HEADERS})
    add_library(mqfilter SHARED mqfilter.c)
    target_link_libraries(mqfilter maxscale-common ${RABBITMQ_LIBRARIES})
    add_dependencies(mqfilter pcre2)
    install(TARGETS mqfilter DESTINATION ${MAXSCALE_LIBDIR})
  else()
    message(WARNING "Could not find librabbitmq, the mqfilter will not be built.")
  endif()
endif()

add_library(regexfilter SHARED regexfilter.c)
target_link_libraries(regexfilter maxscale-common)
add_dependencies(regexfilter pcre2)
set_target_properties(regexfilter PROPERTIES VERSION "1.1.0")
install(TARGETS regexfilter DESTINATION ${MAXSCALE_LIBDIR})

add_library(testfilter SHARED testfilter.c)
target_link_libraries(testfilter maxscale-common)
set_target_properties(testfilter PROPERTIES VERSION "1.0.0")
install(TARGETS testfilter DESTINATION ${MAXSCALE_LIBDIR})

add_library(qlafilter SHARED qlafilter.c)
target_link_libraries(qlafilter maxscale-common)
set_target_properties(qlafilter PROPERTIES VERSION "1.1.1")
install(TARGETS qlafilter DESTINATION ${MAXSCALE_LIBDIR})

add_library(tee SHARED tee.c)
target_link_libraries(tee maxscale-common)
set_target_properties(tee PROPERTIES VERSION "1.0.0")
install(TARGETS tee DESTINATION ${MAXSCALE_LIBDIR})

add_library(topfilter SHARED topfilter.c)
target_link_libraries(topfilter maxscale-common)
set_target_properties(topfilter PROPERTIES VERSION "1.0.1")
install(TARGETS topfilter DESTINATION ${MAXSCALE_LIBDIR})

if(BUILD_LUAFILTER)
  find_package(Lua)
  if(LUA_FOUND)
    include_directories(${LUA_INCLUDE_DIR})
    add_library(luafilter SHARED luafilter.c)
    target_link_libraries(luafilter maxscale-common ${LUA_LIBRARIES})
    install(TARGETS luafilter DESTINATION ${MAXSCALE_LIBDIR})
  else()
    message(STATUS "Lua was not found, luafilter will not be built.")
  endif()
endif()

add_library(namedserverfilter SHARED namedserverfilter.c)
target_link_libraries(namedserverfilter maxscale-common)
set_target_properties(namedserverfilter PROPERTIES VERSION "1.1.0")
install(TARGETS namedserverfilter DESTINATION ${MAXSCALE_LIBDIR})

if(BUILD_SLAVELAG)
  add_library(slavelag SHARED slavelag.c)
  target_link_libraries(slavelag maxscale-common)
  set_target_properties(slavelag PROPERTIES VERSION "1.1.0")
  install(TARGETS slavelag DESTINATION ${MAXSCALE_LIBDIR})
endif()

add_subdirectory(hint)
add_subdirectory(dbfwfilter)

if(BUILD_TESTS)
  add_subdirectory(test)
endif()
